/* 金额指令，数字滚动效果 */
avalon.directive('count', {
    update: function (vdom, value) {
        /* console.log('vdom',vdom, 'value',value); */
        var dom = vdom.dom;
        if(!dom.id) dom.id = 'dom-' + (new Date()).getTime();
        var startVal = Number(value) / 10;

        if(value==='') return false;
        setTimeout(function(){
            var countup = new CountUp(dom.id, startVal, value, 2, 1);
            countup.start(function(){
                var n = dom.innerText,
                    numStr = dom.innerText.indexOf('.')===-1 ? n+'.00' : n+'',
                    dotIndex = numStr.indexOf('.');
                dom.innerHTML = numStr.slice(0, dotIndex)+'<i class="dotNum">'+ numStr.slice(dotIndex)+'</i>';
            });
        },0);
    }
})
